{php $chuangyejindata = \Phpcmf\Service::M()->table('1_quan_form_chuangyejin_shezhi')->where('dirname', 'chuangyejin')->getRow();}
{php $chuangyejindata['setting'] = dr_string2array($chuangyejindata['setting']);}
	
{php $chuangyejinmingcheng = $chuangyejindata['setting']['pages']['chuangyejin_name'];}
{php $chuangyejindanwei = $chuangyejindata['setting']['pages']['chuangyejin_danwei'];}
{php $chuangyejinjieguo = $chuangyejindata['setting']['pages']['chuangyejin_jieguo'];}
{php $chuangyejinshuoming = $chuangyejindata['setting']['pages']['chuangyejin_shuoming'];}
<div class="d-shang-15 d-xia-10">
	{if $chuangyejinjieguo==1}
	<div class="d-kuan d-beijingyanse-lv d-yuanjiao-10 d-xia-10 ">
		<div class="d-neikuang-10 d-buhuanhang d-wenzi-juzhong">
			<div class="d-kuan-33 ">
				<div class="d-wenzi-26 " style="color: #f44500;">
					{sum sum=chuangyejin action=table table=1_quan_form_chuangyejin tieziid=$id return=zongshenqing}
					{sum sum=jine action=table table=1_quan_form_chuangyejin tieziid=$id return=zongshenqingjine}
					{php $zonghe=(int)$zongshenqing_sum + (int)$zongshenqingjine_sum;}
					{$zonghe} <span class="d-wenzi-12">{$chuangyejindanwei}</span>
				</div>
				<div class="d-wenzi-12 d-shang-5 d-zitiyanse-hui">已发放{$chuangyejinmingcheng}</div>
			</div>
			<div class="d-kuan-33 ">
				<div class="d-wenzi-26 " style="color: #f44500;">
					{count action=table table=1_quan_form_chuangyejin tieziid=$id return=zongshenqing}
					{$zongshenqing_count}<span class="d-wenzi-12 ">位</span>
				</div>
				<div class="d-wenzi-12 d-shang-5 d-zitiyanse-hui">申请人</div>
			</div>
			<div class="d-kuan-33 ">
				<div class="d-wenzi-26 " style="color: #f44500;">
					{php $shengyu = (int)$fuchijine - (int)$zonghe;}{$shengyu}<span class="d-wenzi-12 ">{$chuangyejindanwei}</span>
				</div>
				<div class="d-wenzi-12 d-shang-5 d-zitiyanse-hui">剩余{$chuangyejinmingcheng}</div>
			</div>
		</div>
	</div>
	
	{/if}
	<div class="d-kuan d-beijingyanse-lv d-yuanjiao-10 ">
		<div class="d-neikuang-10">
			<div class="col-md-12">
				<div class="d-jiacu" style="color: #009c00;">{$chuangyejinmingcheng}资料
				    
				</div>
				<div>
					<span class="d-zitiyanse-hui">总 {$chuangyejinmingcheng}</span>
					<span class="d-wenzi-26 d-shang-10" style="color: #009c00;">{$fuchijine}</span>
					<span>{$chuangyejindanwei}</span>
				</div>
				<div class="d-shang-10">
					<span class="d-zitiyanse-hui">人数</span>
					<span class="d-zuo-10">
						{$fcsl} (位)
					</span>
				</div>
				<div class="d-shang-10">
					<span class="d-zitiyanse-hui">每人可申请 </span>
					<span class="d-zuo-10">
						{$sqsc} 次
					</span>
				</div>
				<div class="d-shang-10">
					<span class="d-zitiyanse-hui">结束时间</span>
					<span class="d-zuo-10">
						{dr_date($cyjssj, 'Y-m-d')} 
					</span>
				
				</div>
				<div class="d-clear"></div>
			</div>
		</div>
		<div class="d-clear"></div>
		<!---->
		<div class="d-shang-15">
			<div class="d-yuanjiao-10-10-xia d-beijing-lv">
				<div class="d-jindu-biaoti-lv" >申请进度</div>
				
					<div class="d-jindu-kuang">
						<div class="d-jindu-neikuang">
							<div class="d-jindu-kuan100">
								<div class="d-jindu-tu d-jindu-tu-weizhi d-yuanjiao-10">
									<img src="{HOME_THEME_PATH}web/img/qiuzu.png" class="d-beijing-baise">
								</div>
							</div>
				            <div class="d-jindu-ziti {if $qiuzubiao}d-jiacu d-beijing-wenzi-lv{/if}">
								进行中...
							</div>
							<div class="d-jindu-riqi ">
								{dr_date($inputtime, 'Y-m-d')}
							</div>
						</div>
				        <div class="d-jindu-neikuang d-quxian-0">
							<div class="d-jindu-kuan100">
									<div class="d-jindu-jtiao-lv d-jindu-right d-jindu-lv {if strtotime($cyjssj) > time()}d-jindu-guodu-lv{/if}">
									</div>
									{if strtotime($cyjssj) < time()}
										<div class="d-jindu-tu d-jindu-tu-weizhi d-yuanjiao-10">
											<img src="{HOME_THEME_PATH}web/img/qiuzu.png" class="d-beijing-baise">
										</div>
									{else}
										<div class="d-jindu-tu d-jindu-tu-weizhi d-yuanjiao-10">
											<img src="{HOME_THEME_PATH}web/img/qiushijian.png" class="d-beijing-baise">
										</div>
									{/if}
							</div>
							<a id="d_bug_paiqi_{$id}" data-id="{$id}" data-quanid="{$index.id}" class="d-qiuzu-jindu">
								<div class="d-jindu-ziti {if strtotime($cyjssj) < time()}d-jiacu d-beijing-wenzi-lv{/if}">
									申请结束
								</div>
							</a>
							<div class="d-jindu-riqi">
								{dr_date($cyjssj, 'Y-m-d')}
							</div>
						</div>
						
						
					</div>
				</div>
		</div>
		<!---->
	</div>
	<div class="d-clear"></div>
</div>
<div class="d-yincangyd">
	<div class="d-kuan d-buhuanhang d-shang-15 d-xia-10 ">
		{loop $fuchiguige $i $v}
			<div class="d-kuan d-xia-15 d-yuanjiao-10 d-neikuang-10">
				<div class="d-kuan d-juzhong  d-bian-1-hui d-yuanjiao-10 d-neikuang-10">
				<span class="d-zitiyanse-hui">{$chuangyejinmingcheng}</span> <span class="d-wenzi-18 d-shang-10" style="color: #009c00;">{$v[1]}</span> <span class="d-zitiyanse-hui">{$chuangyejindanwei}</span>
					<div class="d-zitiyanse-hui d-wenzi-12">申请费用：{$v[2]}/元 </div>
					<div class="d-kua">
						<span class="d-wenzi-12 d-shang-10">可用：</span>
					</div>
					<div class="d-kua">
						<span class="d-wenzi-12 d-shang-10">{$v[1] + $v[2]} {$chuangyejindanwei} {$chuangyejinmingcheng}</span>
					</div>
					<div class="d-kua">
						
						{php $benrenyue=number_format($member.money, 2);}
						{php $chuangyejine =number_format($v[2]);}
						{if $chuangyejine > $benrenyue}
						<a href="{dr_url('quan/chuangyejin/index',['id'=>$id,'cid'=>$i])}" class="d-div-you d-wenzi-12 tag_chuangyejin_huodong-0" data-zhi="{$chuangyejine}" >先充值，后申请</a>
						{else}
						<button type="button" class="btn btn-default btn-xs d-div-you tag_chuangyejin_queren" data-toggle="modal" data-target="#myModal" data-shenqingfei="{$chuangyejine}" data-jin="{$v[1]}" data-tieid="{$id}" data-i="{$i}">
						  申请
						</button>
						<!--a class="d-div-you d-wenzi-12 tag_chuangyejin_shenqing" data-target="#myModal" data-toggle="modal" data-shenqingfei="{$chuangyejine}" data-jin="{$v[1]}">
							申请
						</a-->
						{/if}
						
					</div>
					<div class="d-clear"></div>
				</div>
				<div class="d-kuan d-shang-5 d-beijing-hei-f0 d-wenzi-12  d-yuanjiao-10 d-neikuang-10">
					{$v[3]}
				</div>
			</div>
		{/loop}
	</div>
</div>
<div class="d-yincangpc">

	<div class="d-kuan d-shang-15 d-xia-10 ">
		{loop $fuchiguige $i $v}
			<div class="d-kuan d-xia-15 d-yuanjiao-10 d-neikuang-10">
				<div class="d-kuan d-juzhong  d-bian-1-hui d-yuanjiao-10 d-neikuang-10">
				<span class="d-zitiyanse-hui">{$chuangyejinmingcheng}</span> <span class="d-wenzi-18 d-shang-10" style="color: #009c00;">{$v[1]}</span> <span class="d-zitiyanse-hui">{$chuangyejindanwei}</span>
					<div class="d-zitiyanse-hui d-wenzi-12">申请费用：{$v[2]}/元 </div>
					<div class="d-kua">
						<span class="d-wenzi-12 d-shang-10">可用：</span>
					</div>
					<div class="d-kua">
						<span class="d-wenzi-12 d-shang-10">{$v[1] + $v[2]} {$chuangyejindanwei} {$chuangyejinmingcheng}</span>
					</div>
					<div class="d-kua">
						
						{php $benrenyue=number_format($member.money, 2);}
						{php $chuangyejine =number_format($v[2]);}
						{if $chuangyejine > $benrenyue}
						<a href="{dr_url('quan/chuangyejin/index',['id'=>$id,'cid'=>$i])}" class="d-div-you d-wenzi-12 tag_chuangyejin_huodong-0" data-zhi="{$chuangyejine}" >先充值，后申请</a>
						{else}
						<button type="button" class="btn btn-default btn-xs d-div-you tag_chuangyejin_queren" data-toggle="modal" data-target="#myModal" data-shenqingfei="{$chuangyejine}" data-jin="{$v[1]}" data-tieid="{$id}" data-i="{$i}">
						  申请
						</button>
						<!--a class="d-div-you d-wenzi-12 tag_chuangyejin_shenqing" data-target="#myModal" data-toggle="modal" data-shenqingfei="{$chuangyejine}" data-jin="{$v[1]}">
							申请
						</a-->
						{/if}
						
					</div>
					<div class="d-clear"></div>
				</div>
				<div class="d-kuan d-shang-5 d-beijing-hei-f0 d-wenzi-12  d-yuanjiao-10 d-neikuang-10">
					{$v[3]}
				</div>
			</div>
		{/loop}
	</div>

</div>
<div class="d-neikuang-10">
<div class="d-kuan d-beijingyanse-lv d-yuanjiao-10 ">
		<div class="d-neikuang-10">
			<div class="col-md-12">
				<!--div class="d-jiacu" style="color: #009c00;">{$chuangyejinmingcheng}资料
				    
				</div-->
				
				{if $member}
				<div class="d-shang-10 d-xia-10">
					<span class="d-zitiyanse-hui">您已经申请</span>
					<span class="d-zuo-10" style="color: #f44500;">
						{count action=table table=1_quan_form_chuangyejin tieziid=$id uid=$member.id return=shenqing}
						{$shenqing_count}
					</span> (次)
					
				</div>
				<div class="d-shang-10 d-xia-10">
					<span class="d-zitiyanse-hui">您已经申请</span>
					<span class="d-zuo-10" style="color: #f44500;">
						{sum sum=chuangyejin action=table table=1_quan_form_chuangyejin tieziid=$id uid=$member.id return=shenqing}
						{sum sum=jine action=table table=1_quan_form_chuangyejin tieziid=$id uid=$member.id return=shenqingjine}
						{php (int)$uidhe=$shenqing_sum + (int)$shenqingjine_sum;}
						{$uidhe}
					</span> {$chuangyejindanwei}{$chuangyejinmingcheng }
					
				</div>
				{/if}
				
				<div class="d-clear"></div>
			</div>
		</div>
		<div class="d-clear"></div>
	</div>
</div>
	<div class="d-kuan d-xia-10 ">
		<div class="d-kuan d-xia-15 d-yuanjiao-10 d-neikuang-10">
			<div class="d-kuan d-juzhong d-wenzi-12 d-bian-1-hui d-yuanjiao-10 d-neikuang-10">
				注明：{$chuangyejinshuoming} （本活动所有内容及相关规则均由‘{if $user.name}
										{$user.name}
									{elseif $userweixin.nickname}
										{$userweixin.nickname}
									{else}
										{$user.username}
									{/if}’制定并享有最终解释权）
			</div>
		</div>
	</div>

<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <!--模态框的头部内容-->
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="myModalLabel">确认申请</h4>
            </div>
            <!--模态框的主体内容-->
            <div class="modal-body">
                <p>{$chuangyejinshuoming}</p>
            </div>
            <!--模态框的尾部内容-->
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary d-queren tag_chuangyejin_queren_3" data-dismiss="modal">确认申请</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<style>
.xia-20 {
	margin-bottom: 20px;
}
.d-yincangyd {
	display:block;
}
.d-yincangpc {
	display:none;
}
.modal-open {
    overflow: auto;
}
@media screen and (max-width: 990px) { 
	.d-yincangyd {
		display:none;
	}
	.d-yincangpc {
		display:block;
	}
}
</style>

<script>
	$(".tag_chuangyejin_huodong").click(function(){
		 var zhi = $(this).data("zhi");
		 dr_iframe("{dr_lang('充值')}", "{dr_member_url('pay/recharge/index')}&chuangyejin="+zhi, '30%', '50%');
	});
	$(document).ready(function() { 
		$(".tag_chuangyejin_queren").click(function(){
			 var shenqingfei = $(this).data("shenqingfei");
			 var jin = $(this).data("jin");
			 var tieid =$(this).data("tieid");
			 var i =$(this).data("i");
			 var confirmButton = $('.d-queren'); 
			 confirmButton.attr('data-shenqingfei', shenqingfei);  
			 confirmButton.attr('data-jin', jin);
			 confirmButton.attr('data-tieid', tieid);
			 confirmButton.attr('data-i', i);
			 $('.tag_chuangyejin_queren_3').data("shenqingfei", shenqingfei).data("jin", jin).data("tieid", tieid).data("i", i);
		});
		
		$('.tag_chuangyejin_queren_3').on('click', function() {  
		        var shenqingfei = $(this).data("shenqingfei");  
		        var jin = $(this).data("jin");  
				var tieid =$(this).data("tieid");
				var i =$(this).data("i");
		        //console.log('shenqingfei', shenqingfei);  
		        //console.log('jin', jin);  
		        // 如果你想要调用另一个函数并传递这些值，你可以这样做：  
		        handleConfirm(shenqingfei, jin, tieid,i);  
		    });
	});
	// 另一个函数，处理从“确认申请”按钮传递过来的数据  
	    function handleConfirm(shenqingfei, jin, tieid,i) {  
	        // 在这里处理数据，例如发送AJAX请求等  
	        //console.log('shenqingfei:', shenqingfei, 'and jin:', jin, 'and tieid:', tieid);
			$.get("/index.php?is_ajax=1&s=member&app=chuangyejin&c=home&m=index&shenqingfei="+shenqingfei+"&jin="+jin+"&tieid="+tieid+"&i="+i, function(data){
				 dr_cmf_tips(data.code, data.msg);
			    if (data.msg ==="申请成功") {
					window.location.reload();
			       
			    } else {
					
			    	
			    }
			}, 'json');
			
	    }
	$(".tag_chuangyejin_shenqing").click(function(){
		 var shenqingfei = $(this).data("shenqingfei");
		 var jin = $(this).data("jin");
		 dr_iframe("{dr_lang('充值')}", "{dr_member_url('pay/recharge/index')}&chuangyejin="+zhi, '30%', '50%');
	});

</script>